<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------

use app\api\middleware\BlockerMiddleware;
use think\facade\Route;
use think\facade\Config;
use think\Response;


Route::group(function () {
    //账号密码登录

    Route::get('task/cert', 'v1.task.TaskController/cert')->option(['real_name' => '考试题目']);
    Route::post('login/login', 'v1.LoginController/login')->name('login')->option(['real_name' => '账号密码登录']);
    Route::post('login/send', 'v1.LoginController/send')->name('login')->option(['real_name' => '账号密码登录']);
    Route::post('login/pass', 'v1.LoginController/pass')->name('login')->option(['real_name' => '账号密码登录']);
    Route::post('login/ver', 'v1.LoginController/ver')->name('login')->option(['real_name' => '账号密码登录']);
    Route::get('login/ver', 'v1.LoginController/ver')->name('login')->option(['real_name' => '账号密码登录']);
})->middleware(\app\http\middleware\AllowOriginMiddleware::class)
    ->option(['mark' => 'base', 'mark_name' => '基础接口']);

Route::group(function () {
    //账号密码登录
    Route::post('login', 'v1.LoginController/login')->name('login')->option(['real_name' => '账号密码登录']);
    Route::post('index/course', 'v1.IndexController/index')->name('indexCourse')->option(['real_name' => '人员学习']);
    Route::post('plan/course', 'v1.plan.PlanController/course')->name('planCourse')->option(['real_name' => '人员学习']);
    Route::post('plan/courseware', 'v1.plan.PlanController/courseware')->name('planCourseware')->option(['real_name' => '人员学习']);
    Route::post('plan/test_topic', 'v1.plan.PlanController/test_topic')->option(['real_name' => '练习题']);
    Route::post('course/study', 'v1.plan.CourseController/study')->option(['real_name' => '开始学习']);
    Route::post('course/progress', 'v1.plan.CourseController/progress')->option(['real_name' => '视频播放进度']);
    Route::post('course/end', 'v1.plan.CourseController/end')->option(['real_name' => '学习完成']);
    Route::post('exam/index', 'v1.plan.ExamController/index')->option(['real_name' => '学习完成']);
    Route::post('exam/examination', 'v1.plan.ExamController/examination')->option(['real_name' => '考试题目']);
    Route::post('exam/exam_submit', 'v1.plan.ExamController/exam_submit')->option(['real_name' => '考试题目']);


    Route::post('article/type', 'v1.article.ArticleController/type')->option(['real_name' => '考试题目']);
    Route::post('article/index', 'v1.article.ArticleController/index')->option(['real_name' => '考试题目']);
    Route::post('article/detail', 'v1.article.ArticleController/detail')->option(['real_name' => '考试题目']);
    Route::post('disclose/index', 'v1.disclose.DiscloseController/index')->option(['real_name' => '考试题目']);
    Route::post('disclose/detail', 'v1.disclose.DiscloseController/detail')->option(['real_name' => '考试题目']);
    Route::post('upload/base64', 'v1.common.UploadController/base64')->option(['real_name' => '考试题目']);
    Route::post('upload/file', 'v1.common.UploadController/file')->option(['real_name' => '考试题目']);

    Route::post('disclose/submit', 'v1.disclose.DiscloseController/submit')->option(['real_name' => '考试题目']);
    Route::post('disclose/record', 'v1.disclose.DiscloseController/record')->option(['real_name' => '考试题目']);
    Route::post('disclose/dynamics_save', 'v1.disclose.DiscloseController/dynamics_save')->option(['real_name' => '考试题目']);

    Route::post('train/index', 'v1.train.TrainController/index')->option(['real_name' => '考试题目']);
    Route::post('train/submit', 'v1.train.TrainController/submit')->option(['real_name' => '考试题目']);
    Route::post('face/check', 'v1.common.FaceController/check')->option(['real_name' => '考试题目']);
    Route::post('staff/info', 'v1.staff.StaffController/info')->option(['real_name' => '考试题目']);
    Route::post('staff/pass', 'v1.staff.StaffController/pass')->option(['real_name' => '考试题目']);
    Route::post('index/about', 'v1.IndexController/about')->option(['real_name' => '考试题目']);
    Route::post('train/detail', 'v1.train.TrainController/detail')->option(['real_name' => '考试题目']);

    Route::post('staff/info2', 'v1.staff.StaffController/info2')->option(['real_name' => '考试题目']);
    Route::post('exam/check', 'v1.plan.ExamController/check')->option(['real_name' => '考试题目']);
    Route::post('plan/sign', 'v1.plan.PlanController/sign')->option(['real_name' => '培训签字']);
    Route::post('plan/staff', 'v1.plan.PlanController/staff')->option(['real_name' => '培训签字']);

})->middleware(\app\http\middleware\AllowOriginMiddleware::class)
    ->middleware(\app\api\middleware\StationOpenMiddleware::class)
    ->middleware(\app\api\middleware\AuthTokenMiddleware::class)
    ->option(['mark' => 'base', 'mark_name' => '基础接口']);


Route::miss(function () {
    if (app()->request->isOptions()) {
        $header = Config::get('cookie.header');
        unset($header['Access-Control-Allow-Credentials']);
        return Response::create('ok')->code(200)->header($header);
    } else
        return Response::create()->code(404);
});
